﻿using Shake.Framework.Infrastructure;
using Shake.Framework.Utility;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;


using System.IO;
using System.Reflection;
using System.Linq;
using Shake.Framework.Repository;
using Shake.Framework.Services;

namespace Shake.Framework.Database
{
    //public class DatabaseContext : DbContext
    //{
    //    public IShakeCacheManager<object> ShakeCacheManager { get; set; }

    //    static DatabaseContext()
    //    {
    //        System.Data.Entity.Database.SetInitializer<DatabaseContext>(null);
    //    }

    //    public DatabaseContext()
    //        : base("name=DefaultConnection")
    //    {
    //        Configuration.ProxyCreationEnabled = false;
    //        Configuration.LazyLoadingEnabled = false;
    //    }

    //    public DatabaseContext(string nameOrConnectionString)
    //        : base(nameOrConnectionString)
    //    {
    //    }

    //    public DatabaseContext(string nameOrConnectionString, DbCompiledModel model)
    //        : base(nameOrConnectionString, model)
    //    {
    //    }

    //    public DatabaseContext(DbConnection existingConnection, bool contextOwnsConnection)
    //        : base(existingConnection, contextOwnsConnection)
    //    {
    //    }

    //    public DatabaseContext(DbConnection existingConnection, DbCompiledModel model, bool contextOwnsConnection)
    //        : base(existingConnection, model, contextOwnsConnection)
    //    {
    //    }

    //    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    //    {
    //        var assembly = FeatureUtil.GetFeatureAssembly().ToList();
    //        assembly.ForEach(t => modelBuilder.Configurations.AddFromAssembly(t));
    //        modelBuilder.Configurations.AddFromAssembly(Assembly.GetExecutingAssembly());
    //    }

    //    #region 文章

    //    //public DbSet<Category> Categories { get; set; }

    //    #endregion

    //    public override int SaveChanges()
    //    {
    //        try
    //        {
    //            return base.SaveChanges();
    //        }
    //        catch (DBConcurrencyException ex)
    //        {
    //            throw ex;
    //        }
    //        catch (DbUpdateException ex)
    //        {
    //            throw ex;
    //        }
    //    }
    //}
}
